﻿<Application x:Class="Reactor.MiniManager.App"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:Controls="clr-namespace:Reactor.MiniManager.Controls" StartupUri="MainWindow.xaml">
    <Application.Resources>
        <ResourceDictionary>
            <!-- This storyboard will make the image grow to double its size in 0.2 seconds -->
            <Storyboard x:Key="expandStoryboard">
                <DoubleAnimation Storyboard.TargetProperty="RenderTransform.ScaleX" To="1.5" Duration="0:0:0.2" />
                <DoubleAnimation Storyboard.TargetProperty="RenderTransform.ScaleY" To="1.5" Duration="0:0:0.2" />
            </Storyboard>

            <!-- This storyboard will make the image revert to its original size -->
            <Storyboard x:Key="shrinkStoryboard">
                <DoubleAnimation Storyboard.TargetProperty="RenderTransform.ScaleX" To="1" Duration="0:0:0.2" />
                <DoubleAnimation Storyboard.TargetProperty="RenderTransform.ScaleY" To="1" Duration="0:0:0.2" />
            </Storyboard>

            <Storyboard x:Key="fastShrinkStoryboard">
                <DoubleAnimation Storyboard.TargetProperty="RenderTransform.ScaleX" To="1" Duration="0:0:0.1" />
                <DoubleAnimation Storyboard.TargetProperty="RenderTransform.ScaleY" To="1" Duration="0:0:0.1" />
            </Storyboard>
            <Storyboard x:Key="fastExpandStoryboard">
                <DoubleAnimation Storyboard.TargetProperty="RenderTransform.ScaleX" To="1.5" Duration="0:0:0.1" />
                <DoubleAnimation Storyboard.TargetProperty="RenderTransform.ScaleY" To="1.5" Duration="0:0:0.1" />
            </Storyboard>

            <Style x:Key="AnimatedImage" TargetType ="{x:Type Image}">
                <Setter Property="Width" Value="20" />
                <Setter Property="Margin" Value="2" />
                <Setter Property="RenderTransform">
                    <Setter.Value>
                        <ScaleTransform ScaleX="1" ScaleY="1" CenterX="10" CenterY="10"/>
                    </Setter.Value>
                </Setter>
                <Style.Triggers>
                    <EventTrigger RoutedEvent="Image.MouseDown">
                        <BeginStoryboard Storyboard="{StaticResource fastShrinkStoryboard}" />
                    </EventTrigger>
                    <EventTrigger RoutedEvent="Image.MouseUp">
                        <BeginStoryboard Storyboard="{StaticResource fastExpandStoryboard}" />
                    </EventTrigger>

                    <EventTrigger RoutedEvent="Image.MouseEnter">
                        <BeginStoryboard Storyboard="{StaticResource expandStoryboard}" />
                    </EventTrigger>
                    <EventTrigger RoutedEvent="Image.MouseLeave">
                        <BeginStoryboard Storyboard="{StaticResource shrinkStoryboard}" />
                    </EventTrigger>
                </Style.Triggers>
            </Style>

            <Style TargetType="Controls:ImageButton">
                <Setter Property="Template">
                    <Setter.Value>
                        <ControlTemplate TargetType="{x:Type Controls:ImageButton}">
                            <Image Source="{TemplateBinding ImageSource}" Style="{StaticResource AnimatedImage}"/>
                        </ControlTemplate>
                    </Setter.Value>
                </Setter>
            </Style>
        </ResourceDictionary>
    </Application.Resources>
</Application>
